Skip to content

Reduce SQL queries of the timeline, reservable items and config reads - #90

Open
Lainow wants to merge 2 commits into
11.0/bugfixesfrom
perf/reduce-sql-queries
Open

Lainow wants to merge 2 commits into
11.0/bugfixesfrom
perf/reduce-sql-queries

Conversation

@Lainow

@Lainow Lainow commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.

Description

Removes per-item SQL queries and caches the plugin configuration, no behaviour or schema change.

  • Timeline: equipment names loaded in one query per itemtype, ticket update right checked once, approve/refuse script emitted once.
  • ReservableItems: assets loaded in one query per itemtype.
  • Configuration kept in memory, cleared on save; redundant isActivated() removed from plugin init.

Benchmark

GLPI 11.0.13, 50 000 reservation requests, one ticket with 1 250 of them, 1 980 reservable items.

Scenario SQL before SQL after Time before Time after
S0 Home page 469 379 1 054 ms 1 002 ms
S1 Ticket with 1 250 requests (page server time) 20 370 6 646 413 ms 110 ms
S4 Reservation question (ReservableItems server time) 4 294 245 179 ms 38 ms
S6 Form editor 1 342 136 355 ms 334 ms
W2 Form submission with a reservation 6 885 2 271 494 ms 493 ms

S1 still takes about 10 s to display fully: the remaining cost is core rendering the 1 250 timeline entries.

Tests

New tests for the grouped name lookup, the single timeline script and the config cache.
9 errors in the full suite are unrelated (8 need an LDAP server, ConfigFormTest::testTabContentIsEmptyForTech already fails on 11.0/bugfixes).

- Timeline hook: resolve equipment names in one query per itemtype and the
  ticket update right once, instead of 6 to 12 queries per request.
- Timeline template: emit the approve/refuse script once, with a delegated
  click handler, instead of one module script per waiting request.
- ReservableItems: load the assets of each itemtype in one query instead of
  one getFromDB() per reservable item.
- ConfigManager: keep the plugin configuration in memory (1 query per
  request instead of 14, 56 in the form editor), reloaded by init() and
  cleared when a configuration value of the plugin is saved.
- setup.php: drop the redundant isActivated() check in plugin init.
GLPI now throws an access denied exception in ajax/common.tabs.php
instead of returning an empty tab (glpi-project/glpi#26257).
@Lainow Lainow self-assigned this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant